/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package br.faimg.pomar.modelo.dao;

import br.faimg.pomar.modelo.pojo.ConsultaProducao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Juliana
 */
public class ConsultaProducaoDAO{
 
    public List<ConsultaProducao> readByExample(ConsultaProducao pojo) {
        Connection con = null;
        PreparedStatement stm = null;
        ResultSet rs = null;
        String sql = "select * from visao_consulta_producao";
        List<ConsultaProducao> consultaProd = new ArrayList<ConsultaProducao>();

        if (pojo == null) {

            pojo = new ConsultaProducao();
        }

        con = ConnectionManager.getInstance().getConnection();
        try {
            stm = con.prepareStatement(sql);
            rs = stm.executeQuery();

            while (rs.next()) {
                ConsultaProducao temp = new ConsultaProducao();
                temp.setEstacao(rs.getString("estacao"));
                temp.setQtd_prod(rs.getInt("qtd_prod"));
                temp.setCount(rs.getInt("count"));
                temp.setDif(rs.getInt("dif"));
                consultaProd.add(temp);
            }

        } catch (Exception ex) {
            ex.printStackTrace();
        }

        return consultaProd;
    } 
}
